class JQProductSearchService extends global.JQService {
	
    async do_action(){
		console.log('search_list 1111');
		
		if(!this.conn)console.log('do_action::conn error');
		let data_obj = this.req_obj.data_obj;
		let search = null;
		if(data_obj.obj &&  data_obj.obj.search)search = data_obj.obj.search;
		console.log('search_list 22222');
		let inst = global.JQTableIF.instance('cp_table',this.conn);
		
		let alias_keys=['cp_id','cp_name','cp_picture','cp_price','vip_price',
		         'cp_recommend','is_discount','cp_dprice','u_id','cp_count','cp_spell','sort',
				 'menu_sort','menu_id'];
		let a_keys=['cp_id','cp_name','cp_picture','cp_price','vip_price','menu_id',
		         'cp_recommend','is_discount','cp_dprice','cp_count','cp_spell','sort'];
		let alias_a_keys=['cp_id','cp_name','cp_picture','cp_price','vip_price',
		         'cp_recommend','is_discount','cp_dprice','cp_count','cp_spell','sort'];
		let params_a =null;
		let b_table='menu';				
		let b_keys=['menu_id','u_id','sort'];
		let alias_b_keys = ['menu_id','u_id','sort menu_sort'];
		let params_b =this._addUserParams();
		if(data_obj.obj && data_obj.obj.menu_id){
			params_b= this._addParams(['menu_id=',data_obj.obj.menu_id],params_b);
		}
		
		console.log('search_list 3333');
		let joint='inner join';
		let first= 0;
		let size = 10000;	
		let on_a='menu_id';
		let on_b= 'menu_id';
		
		let params=null;
		if(search){
			params = this._addParams(['cp_spell like',`%${search}%`]);
			params = this._addParams(['cp_name like',`%${search}%`],params,'or');
		}
		let order_by='menu_sort desc, sort desc';
		let group_by =null;
		
		let list = await inst.query2(alias_keys,alias_a_keys,a_keys,params_a,
			b_table,alias_b_keys,b_keys,params_b,joint,
		   on_a,on_b,params,first,size,group_by,order_by);
		let wrap = {};
	
		wrap.list=list;   
		
		return wrap;			
	}

}
module.exports = JQProductSearchService;


